package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.NewsAuthDto;
import com.heima.model.wemedia.dtos.WmNewsDto;
import com.heima.model.wemedia.dtos.WmNewsPageReqDto;
import com.heima.model.wemedia.dtos.WmNewsUpOrDownDto;
import com.heima.wemedia.service.WmNewsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/news")
@Api(value = "自媒体文章管理",tags = "自媒体文章管理")
public class WmNewsController {

    @Autowired
    private WmNewsService wmNewsService;

    @ApiOperation("条件查询自媒体文章列表")
    @PostMapping("/list")
    public ResponseResult findAll(@RequestBody WmNewsPageReqDto dto){
        return  wmNewsService.findAll(dto);
    }

    @ApiOperation("查看文章详情")
    @GetMapping("/one/{id}")
    public ResponseResult edit(@PathVariable("id") Integer id){
        return  wmNewsService.getOneById(id);
    }

    @ApiOperation("自媒体文章提交或存草稿")
    @PostMapping("/submit")
    public ResponseResult submitNews(@RequestBody WmNewsDto dto){
        return wmNewsService.submitNews(dto);
    }

    @ApiOperation("文章上下架")
    @PostMapping("/down_or_up")
    public ResponseResult downOrUp(@RequestBody WmNewsUpOrDownDto dto){
        return wmNewsService.downOrUp(dto);
    }

    @ApiOperation("分页查询待人工审核文章列表")
    @PostMapping("/list_vo")
    public ResponseResult auditPageList(@RequestBody NewsAuthDto dto){
        return wmNewsService.auditPageList(dto);
    }

    @ApiOperation("平台管理查看文章详情")
    @GetMapping("/one_vo/{id}")
    public ResponseResult getOneById(@PathVariable("id") Integer id){
        return wmNewsService.getOneById(id);
    }

    @ApiOperation("平台管人工审核文章通过")
    @PostMapping("/auth_pass")
    public ResponseResult auth_pass(@RequestBody NewsAuthDto dto){
        return wmNewsService.authPass(dto);
    }

    @ApiOperation("平台管人工审核文章失败")
    @PostMapping("/auth_fail")
    public ResponseResult auth_fail(@RequestBody NewsAuthDto dto){
        return wmNewsService.authFail(dto);
    }
}
